﻿$(document).ready(function(){

	cleanfrom();
	 if ($("#msg").val() != '' && $("#msg").val() != 'null') {
		 layer.alert($("#msg").val());
	    }
	
	$("#sumbit_btn").on("click",function(){
		
		var login_name = $("#userLoginname").val();
		var password = $("#userPassword").val();
		if(login_name == "" || password==""){
			layer.alert('用户名或密码不能为空!');
			return false;
		}
		loginCheck();
	})
	
	 $("#userPassword").keyup(function(event){
	        if (13 == event.keyCode) {
	          
	        	var login_name = $("#userLoginname").val();
	    		var password = $("#userPassword").val();
	    		if(login_name == "" || password==""){
	    			layer.alert('用户名或密码不能为空!');
	    			return false;
	    		}
	            else {
	            	loginCheck();
	            }
	        }
	    });
	
	

});

function loginCheck(){
	
	var json_str = $("#logo_form").serializeJson();
	
	ajaxRequestJson("loginCheck",json_str,function(sh_result){
		
		if(sh_result != "success"){
			layer.alert(sh_result);
			return false;
		}else{
			window.location.href = "loginsuccess";
		}
		
	});
}
function cleanfrom(){
	$("#userLoginname").val("");
	$("#userPassword").val("");
}
